#if NET7_0_OR_GREATER

global using UnreachableException = System.Diagnostics.UnreachableException;

#else

namespace MoreLinq
{
    using System;

    // Source: https://github.com/dotnet/runtime/blob/v7.0.2/src/libraries/System.Private.CoreLib/src/System/Diagnostics/UnreachableException.cs

    /// <summary>
    /// Exception thrown when the program executes an instruction that was thought to be unreachable.
    /// </summary>

#if !NETSTANDARD1_0
    [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
#endif
#pragma warning disable CA1064 // Exceptions should be public
    sealed class UnreachableException : Exception
#pragma warning restore CA1064 // Exceptions should be public
    {
        public UnreachableException() :
            this(null) { }

        public UnreachableException(string? message) :
            base(message, null) { }

        public UnreachableException(string? message, Exception? innerException) :
            base(message ?? "The program executed an instruction that was thought to be unreachable.",
                 innerException) { }
    }
}

#endif // NET7_0_OR_GREATER
